import utils from './utils.js'

var http='https:';
//wx.90it.com.cn
var r_data={
	url:"https://wx.jianmeijiayuan.com/index.php",
	
	header:{'content-type':'application/x-www-form-urlencoded'},
	
	data:{},
	
	dataType:'json',
	
	timeout:30000,
	
	method:"POST",
	
	success:(res)=>{
		
	},
	
	fail:(res)=>{
		
	},
	
	complete:(res)=>{
		
	}
}

var request=function(data){
	
	var data_btn=JSON.parse(JSON.stringify(r_data));
	
	var mydate=new Date();
	
	let time=Math.round(mydate.getTime()/1000);
	
	let rand=utils.createNonceStr()
	
	let signature=utils.arithmetic(time,rand)
	
	for(var i in data){
		if(i=='url'){
			data_btn['url']+=data[i];
		}else{
			data_btn[i]=data[i];
		}
	}
	
	if(uni.getStorageSync('Authorization')){
		data_btn['header'].Authorization=uni.getStorageSync('Authorization');
	}
	
	data_btn['data'].time=time;
	
	data_btn['data'].rand=rand;
	
	data_btn['data'].signature=signature;
	
	console.log(data_btn)
	
	uni.request(data_btn);
}

export default request